package mysql

import (
	"e_mall_server/models"
	"go.uber.org/zap"
)

/**
 * @Author: zhaobin
 * @Description TODO
 * @Date: 2022-05-10 22:31
 */

// AddGoodsImage  添加商品图片信息
func AddGoodsImage(goodsImage *models.GoodsImage) error {
	zap.L().Debug("mysql.AddGoodsImage()", zap.Any("商品图片信息", goodsImage))
	// 进行数据库添加操作
	return db.Create(goodsImage).Error
}

// GetGoodsImageListByGoodsId 通过商品id查询图片信息查询
func GetGoodsImageListByGoodsId(id int64) []models.GoodsImage {
	var goodsImageList []models.GoodsImage
	db.Where("goods_id = ?", id).Order("sort DESC").Limit(6).Find(&goodsImageList)
	zap.L().Debug("mysql.GetGoodsImageListByGoodsId()", zap.Any("商品图片信息", goodsImageList))
	return goodsImageList
}
